(function(){
    var arrlist=[]
    $.ajax({
        url:"http://chst.vip:1234/api/getindexmenu",
    }).then(res=>{
        res=res.result
        res.forEach((item,index)=>{
            let arr={}
            arr.img=`./assets/images/${index+1}.png`
            arr.name=item.name
            arr.indexmenuId=item.indexmenuId
            arr.titlehref=item.titlehref
            arrlist.push(arr)
        })
        console.log(arrlist);
    let html=arrlist.reduce((value,item,idx)=>{  
        if(idx==7){
            return value+`
                <div class="nav-icon" indexmenuid=${item.indexmenuId}>
                    <a href="#"><img src="${item.img}"class="a${idx}"></a>
                    
                     <p>${item.name}</p>
                </div>
        `
        }
        return value+`
                <div class="nav-icon" indexmenuid=${item.indexmenuId}>
                    <a href="../pages/${item.titlehref}"><img src="${item.img}"class="a${idx}"></a>
                    
                     <p>${item.name}</p>
                </div>
        `
    },"")
    $('nav').append(html)
    $('nav').height("5.49rem")
    
    let flag=false
    $(".nav-icon").eq(7).click(()=>{
        console.log(1);
        if(!flag){
            $('nav').stop().animate({height:"8.27rem"},300)
        }else{
            $('nav').stop().animate({height:"5.49rem"},300)
        }
        flag=!flag
    })
    })

    $.ajax({
        url:"http://chst.vip:1234/api/getmoneyctrl"
    }).then(res=>{
        let html=res.result.reduce((value,item,index)=>{
            return value+`
            <li productId=${item.productId}>
            <a href="../pages/savemoney.html?productid=${item.productId}">
                ${item.productImg2}
                <div class="info-fr">
                    <h4>${item.productName} <span>${item.productPinkage}</span></h4>
                    <span class="fl">${item.productFrom}|${item.productTime}</span>
                    <div class="fr">
                        <i class="iconfont">&#xe804;</i>
                        <span>${item.productComCount}</span>
                    </div>
                 </div>
            </a>
        </li>
            `
        },"")
        $(".info").append(html)
    })
})()